package com.example.script.portal.controller;

import com.example.script.common.api.CommonResult;
import com.example.script.mapper.CommentMapper;
import com.example.script.portal.enums.CommentResult;
import com.example.script.portal.model.dto.CreatCommentForm;
import com.example.script.portal.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "CommentController")
@RestController
@RequestMapping("/Comment")
public class CommentController {
    @Autowired
    private CommentMapper commentMapper;
    @Autowired
    private CommentService commentService;

    @ApiOperation("评论")
    @PostMapping("/addComment")
    public CommonResult<Integer> addComment(@RequestBody CreatCommentForm form){
        CommentResult result=commentService.creatComment(form);
        if (result==CommentResult.COMMENT_SUCCESS){
            return CommonResult.success(1, result.getMessage());
        }
        return CommonResult.failed(result.getMessage());

    }

}
